﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace SMP.Resource
{
    using SMP.Domain;
    public class Donvi_Tinh_Res : BaseDB
    {
        Donvi_Tinh donvi_tinh = new Donvi_Tinh();
        public DataTable GetAll_Donvi_Tinh()
        {
            return ExecuteQuery(@"EXEC GetAll_Donvi_Tinh ");
        }

        public DataTable Get_Mathang_Check_Used_By_Id_Donvi_Tinh(long id_donvi_tinh)
        {
            string sql = string.Format(@"EXEC Get_Mathang_Check_Used_By_Id_Donvi_Tinh {0}", id_donvi_tinh);            
            return ExecuteQuery(sql);
        }

        public bool Delete_Donvi_Tinh(long id_donvi_tinh)
        {
            string sql = string.Format(@"DELETE FROM tb_donvi_tinh WHERE id_donvi_tinh = {0}", id_donvi_tinh);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }

        public bool Insert_Donvi_Tinh(Donvi_Tinh donvi_tinh)
        {
            string sql = string.Format(@"INSERT INTO tb_donvi_tinh(ten_donvi_tinh) VALUES (N'{0}')", donvi_tinh.Ten_Donvi_Tinh);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }

        public bool Update_Donvi_Tinh(Donvi_Tinh donvi_tinh)
        {
            string sql = string.Format(@"UPDATE tb_donvi_tinh SET ten_donvi_tinh = N'{0}' ", donvi_tinh.Ten_Donvi_Tinh);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }






    }
}
